package xyz.jcat.seata.example.order.dubbo;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import xyz.jcat.seata.example.api.IOrderService;
import xyz.jcat.seata.example.api.dto.SaleDto;
import xyz.jcat.seata.example.order.domain.dao.IOrderDao;
import xyz.jcat.seata.example.order.domain.po.OrderPo;

import java.util.Date;

@DubboService
public class OrderService implements IOrderService {

    @Autowired
    private IOrderDao orderDao;

    @Override
    public void addOrder(SaleDto saleDto) {
        OrderPo orderPo = new OrderPo();
        orderPo.setUserId(saleDto.getUserId());
        orderPo.setItemId(saleDto.getItemId());
        orderPo.setNum(saleDto.getNum());
        orderPo.setMoney(saleDto.getMoney());
        orderPo.setCreateTime(new Date());
        orderDao.insert(orderPo);
    }

}
